class ResourcePlugin {
  constructor(options){
    this.filename = options.filename
  }
  apply(compiler){
    compiler.hooks.emit.tap('ResourcePlugin', (stats)=>{
      const assets = stats.assets
      let content = `### 资源名称       资源大小\n\r`
      Object.entries(assets).forEach(([name,stateObj])=>{
        content+=`- ${name}       ${stateObj.size()}\n\r`
      })
      assets[this.filename] = {
        source(){
          return content
        },
        size(){
          return content.length
        }
      }
    })
  }
}
module.exports = ResourcePlugin